#include "TileList.h"

TileList::TileList()
{
	head = NULL;
}
TileList::TileList(Tile * headTile)
{
	head = new List<Tile>(headTile, NULL);
}
TileList::~TileList()
{
	printf("deleting tile list\n");
	List<Tile> * search = head;
	while(search)
	{
		search = search->RemoveList();
	}
	head = NULL;
	printf("done deleting tiles\n");
}
List<Tile> * TileList::Add(Tile * payload)
{
	head = new List<Tile>(payload, head);
	return head;
}
void TileList::Remove(Tile * point)
{		
	List<Tile> * search = head;
	while(search)
	{
		if(search->payload && search->payload ==  point)
		{
			if(search == head)
			{
				head = search->next;
			}
			search = search->Remove();
			break;
		}
		else
			search = search->next;
	}	
}